package cn.samler.diandi.api.controller;

import cn.samler.diandi.api.model.io.Response;
import cn.samler.diandi.api.service.UploadService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("file")
public class FileController {
    private final UploadService uploadService;

    public FileController(UploadService uploadService) {
        this.uploadService = uploadService;
    }

    @PostMapping("upload")
    public Response upload(@RequestParam("file") MultipartFile file) {
        return uploadService.upload(file);
    }
}
